package com.anxin.act.mattersProcess.web;

import java.util.List;

import com.anxin.act.mattersProcess.entity.WfMattersProcess;
import com.anxin.act.mattersProcess.service.WfMattersProcessService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anxin.framework.aspectj.lang.annotation.Log;
import com.anxin.framework.aspectj.lang.enums.BusinessType;
import com.anxin.framework.web.controller.BaseController;
import com.anxin.framework.web.entity.AjaxResult;
import com.anxin.common.utils.poi.ExcelUtil;
import com.anxin.framework.web.page.TableDataInfo;

/**
 * 事项流程
Controller
 *
 * @author jbs
 * @date 2022-04-29
 */
//@Api(tags = "事项流程" )
@RestController
@RequestMapping("/process/wfMattersProcess")
public class WfMattersProcessController extends BaseController{
    @Autowired
    private WfMattersProcessService wfMattersProcessService;

    /**
     * 查询事项流程列表
     */
    //@ApiOperation(value="查询事项流程列表" ,notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:mattersProcess:view')")
    @GetMapping("/list")
    @Log(title = "查询事项流程列表", businessType = BusinessType.LIST)
    public TableDataInfo<List<WfMattersProcess>> list(WfMattersProcess wfMattersProcess){
        startPage();
        List<WfMattersProcess> list = wfMattersProcessService.findList(wfMattersProcess);
        return getDataTable(list);
    }


    /**
     * 查询全部事项流程
     */
    //@ApiOperation(value="查询全部事项流程" ,notes="作者:jbs")
    @GetMapping("/allList")
    @Log(title = "查询事项流程列表", businessType = BusinessType.LIST)
    public TableDataInfo<List<WfMattersProcess>> allList(){
        List<WfMattersProcess> list = wfMattersProcessService.findList(new WfMattersProcess());
        return getDataTable(list);
    }


    /**
     * 导出事项流程列表
     */
    //@ApiOperation(value="导出事项流程列表",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:mattersProcess:export')")
    @Log(title = "事项流程", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WfMattersProcess wfMattersProcess) {
        List<WfMattersProcess> list = wfMattersProcessService.findList(wfMattersProcess);
        ExcelUtil<WfMattersProcess> util = new ExcelUtil<WfMattersProcess>(WfMattersProcess.class);
        return util.exportExcel(list, "process");
    }

    /**
     * 获取事项流程详细信息
     */
    //@ApiOperation(value="获取事项流程详细信息",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:mattersProcess:view')")
    @GetMapping(value = "/{id}")
    @Log(title = "获取事项流程详细信息", businessType = BusinessType.LIST)
    public AjaxResult<WfMattersProcess> getInfo(@PathVariable("id") String id){
        return AjaxResult.success(wfMattersProcessService.getById(id));
    }

    /**
     * 保存事项流程

     */
    //@ApiOperation(value="保存事项流程",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:mattersProcess:edit')")
    @Log(title = "事项流程", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody WfMattersProcess wfMattersProcess){
        wfMattersProcessService.save(wfMattersProcess);
        return AjaxResult.success(wfMattersProcess);
    }


    /**
     * 删除事项流程
     */
    //@ApiOperation(value = "删除事项流程", notes = "作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:mattersProcess:remove')")
    @Log(title = "事项流程", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable(("id")) String id) {
        int delete = wfMattersProcessService.deleteById(id);
        if (delete > 0) {
            return toAjax(delete);
        }
        return AjaxResult.error("该事项流程已被使用");
    }
}
